package com.quanjiaolian.chat.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.quanjiaolian.chat.service.ChatService;
import com.quanjiaolian.chat.serviceimpl.ChatServiceImpl;
import com.quanjiaolian.tools.ResponseToJson;

@SuppressWarnings("serial")
public class LoadTypeSelect extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	/**
	 * 动态加载运动分类菜单
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		ChatService cs = new ChatServiceImpl();
		Map<String,Object> resultMap = new HashMap<String,Object>();
		List<Object> result = new ArrayList<Object>();
		List<Map<String,Object>> parentIdList = cs.queryAllType();//查询所有父类运动ID结果集
		for(int i=0;i<parentIdList.size();i++){
			List<Object> list= cs.queryTypeById(parentIdList.get(i).get("st_id").toString());//得到子类结果集
			result.add(list);
		}
		result.add(cs.queryHotSport());
		resultMap.put("result",result);
		ResponseToJson.responseOutWithJson(response,resultMap);
	}

}
